package com.atguigu.lease.common.mybatisplus;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/*
*  自定义的数据(日期)填充处理器
* */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    /*
    *  当mybatisplus检测到 要执行 insert 添加的时候,自动执行以下的方法
    * */
    @Override
    public void insertFill(MetaObject metaObject) {
        System.out.println(metaObject);
        this.strictInsertFill(metaObject,"createTime", Date.class,new Date());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject,"updateTime", Date.class,new Date());
    }
}
